<?php
            


/**
 * Desc:
 * Time: 2021/3/10 4:01 下午
 */

class Index_Page extends PluginMobilePage {

    function main($method)
    {
        global $_P,$_G,$_S,$_C;
        $fromtype = $_P['from'];
        if ($fromtype=='mobile') {
            $test = DemoModel::getFirstDemo();
            $return_client = get_defined_vars();
        return $this->view("demo/question/index", $return_client);
            return; //退出程序执行
        } elseif ($fromtype=='wxapp') {
            $uid = $_G['member']['uid'];
            $themeid = isset($_P['themeid'])?$_P['themeid']:'';
            $from_uid = isset($_P['fromuid'])?$_P['fromuid']:'';
            $workerid = isset($_P['workerid'])?$_P['workerid']:'';
            $params = $_P;
            //基本检测
            $fans = $this->checkuser();
            $system= $_S;
            $config = $_C;//config theme 合并数组
            try {
                $error_txt = '';
                $demo_param = false;
                //反向判断 先出异常 错误 返回或者退出
                if (!$demo_param) {

                    return_json(1,'参数缺失');
                    //存在错误中断返回    定义和查看错误
                    //存在错误码 以及对应信息  message可为空  重新定义需传值
                } else {

                }

                $format_res = [
                    'error_txt'=>$error_txt
                ];
            }catch (Exception $e){
                var_dump($e->getMessage());die();
            }
            return_json(0,'',$format_res);
        }

        if ($_C['status']==0){
            $button['txt']='活动结束';
            $button['type']=0;
        }

        $result=array(
            'test' =>$test,
        );

        if ($fromtype=='mobile') {
            $return_client = get_defined_vars();
        return $this->view("demo/question/index", $return_client);
        } elseif ($fromtype=='wxapp') {
            return_msg($result,'','ajax');
        }

    }
    function main2($method)
    {
        global $_P,$_G,$_S,$_C;
        $fromtype = $_P['from'];
        if ($fromtype=='mobile') {
            $test = DemoModel::getFirstDemo();
            return_msg('出错了！');
        } elseif ($fromtype=='wxapp') {
            $uid = $_G['member']['uid'];
            $themeid = isset($_P['themeid'])?$_P['themeid']:'';
            $from_uid = isset($_P['fromuid'])?$_P['fromuid']:'';
            $workerid = isset($_P['workerid'])?$_P['workerid']:'';
            $params = $_P;
            //基本检测
            $fans = $this->checkuser();
            $system= $_S;
            $config = $_C;//config theme 合并数组
            if ($_C['status']==0){
                $button['txt']='活动结束';
                $button['type']=0;
            }

            return_json(0,'',$format_res);
        }
    }
}